extends Talent
var utils = globalData.infoDs["g_AneHekUtils"]
var base = globalData.infoDs["g_AneHekBase"]
func init():
	name = "免死勋章"
var cnt = 2
func _connect():
	var diff = int(base.getSetting("difficult",1))
	cnt += int(diff/5)
	sys.main.connect("onBattleStart",self,"run")

func run():
	var chas = utils.getAllChas(2)
	for i in chas:
		i.addBuff(BF.new(cnt))

func get_info():
	return "所有角色有2次免疫致命伤害机会[难度越高次数越多]\n此天赋不需要升级"
	
class BF:
	extends Buff
	var canremove:bool = false
	var cnt
	func _init(lv):
		attInit()
		self.cnt = lv
	func _connect():
		masCha.connect("onHurt",self,"run")

	func run(atkinfo):
		if cnt && !atkinfo.isMiss && atkinfo.hurtVal > masCha.att.hp:
			cnt -= 1
			atkinfo.hurtVal = 0
			if !cnt:
				isDel = true